// 应用常量配置文件

// 评分系统配置
export const GRADING_CONFIG = {
  // 分数阈值
  THRESHOLDS: {
    EXCELLENT: 90,
    GOOD: 80,
    FAIR: 70,
    PASS: 60
  },
  
  // 各部分满分
  MAX_SCORES: {
    STRUCTURE: 30,
    CONTENT: 70,
    TOTAL: 100
  },
  
  // 等级映射
  GRADE_MAPPING: {
    90: 'A+',
    85: 'A',
    80: 'A-',
    75: 'B+',
    70: 'B',
    65: 'B-',
    60: 'C+',
    55: 'C',
    50: 'C-',
    0: 'F'
  } as const
} as const

// 编辑器配置
export const EDITOR_CONFIG = {
  // 默认设置
  DEFAULTS: {
    FONT_SIZE: 14,
    FONT_FAMILY: "'Consolas', '微软雅黑', 'Microsoft YaHei', 'Monaco', 'Courier New', monospace",
    MIN_HEIGHT: '400px',
    PADDING: '16px'
  },
  
  // 预览延迟
  PREVIEW_DELAY: 1000,
  
  // 自动保存间隔（毫秒）
  AUTO_SAVE_INTERVAL: 30000
} as const

// 键盘快捷键
export const KEYBOARD_SHORTCUTS = {
  PREVIEW: 'Ctrl+Enter',
  SUBMIT: 'Ctrl+S',
  RESET: 'Ctrl+R',
  CLEAR: 'Ctrl+Shift+C',
  SAVE: 'Ctrl+S'
} as const

// UI 配置
export const UI_CONFIG = {
  // 状态消息显示时间
  STATUS_MESSAGE_DURATION: 3000,
  
  // 动画持续时间
  ANIMATION_DURATION: 300,
  
  // 颜色主题
  COLORS: {
    SUCCESS: 'bg-green-500 text-white',
    ERROR: 'bg-red-500 text-white',
    WARNING: 'bg-yellow-500 text-white',
    INFO: 'bg-blue-500 text-white'
  },
  
  // 分数颜色映射
  SCORE_COLORS: {
    EXCELLENT: 'bg-green-100 text-green-800',
    GOOD: 'bg-blue-100 text-blue-800',
    FAIR: 'bg-yellow-100 text-yellow-800',
    POOR: 'bg-red-100 text-red-800'
  },
  
  // 难度颜色映射
  DIFFICULTY_COLORS: {
    easy: 'bg-green-100 text-green-800',
    medium: 'bg-yellow-100 text-yellow-800',
    hard: 'bg-red-100 text-red-800'
  }
} as const

// 作业模板
export const ASSIGNMENT_TEMPLATES = {
  1: `<!DOCTYPE html>
<html>
<head>
    <title>个人简介</title>
    <meta charset="UTF-8">
</head>
<body>
    <h1>我的个人简介</h1>
    <!-- 在这里添加你的个人信息 -->
</body>
</html>`,
  
  2: `<!DOCTYPE html>
<html>
<head>
    <title>课程表</title>
    <meta charset="UTF-8">
</head>
<body>
    <h1>我的课程表</h1>
    <!-- 在这里创建课程表 -->
</body>
</html>`,
  
  3: `<!DOCTYPE html>
<html>
<head>
    <title>产品展示</title>
    <meta charset="UTF-8">
</head>
<body>
    <h1>产品展示</h1>
    <!-- 在这里展示产品 -->
</body>
</html>`,
  
  4: `<!DOCTYPE html>
<html>
<head>
    <title>导航菜单</title>
    <meta charset="UTF-8">
</head>
<body>
    <!-- 在这里创建导航菜单 -->
</body>
</html>`,
  
  5: `<!DOCTYPE html>
<html>
<head>
    <title>图片画廊</title>
    <meta charset="UTF-8">
</head>
<body>
    <h1>图片画廊</h1>
    <!-- 在这里创建图片画廊 -->
</body>
</html>`,
  
  6: `<!DOCTYPE html>
<html>
<head>
    <title>联系表单</title>
    <meta charset="UTF-8">
</head>
<body>
    <h1>联系我们</h1>
    <!-- 在这里创建联系表单 -->
</body>
</html>`
} as const

// 本地存储键名
export const STORAGE_KEYS = {
  USER_CODE: 'vue_lab_user_code',
  SUBMISSIONS: 'vue_lab_submissions',
  EDITOR_CONFIG: 'vue_lab_editor_config',
  USER_PREFERENCES: 'vue_lab_user_preferences'
} as const

// API 配置（如果需要）
// API配置 - 统一的API基础配置
export const API_CONFIG = {
  // API基础配置
  BASE_URL: import.meta.env.VITE_API_BASE_URL || '/api',
  TIMEOUT: 60000, // 增加到60秒，适应AI接口响应时间
  RETRY_ATTEMPTS: 3,
  // 后端服务配置
  BACKEND_HOST: import.meta.env.VITE_BACKEND_HOST || 'localhost',
  BACKEND_PORT: Number(import.meta.env.VITE_BACKEND_PORT) || 806
} as const

// 验证规则
export const VALIDATION_RULES = {
  // HTML 代码最小长度
  MIN_CODE_LENGTH: 50,
  
  // HTML 代码最大长度
  MAX_CODE_LENGTH: 50000,
  
  // 必需的 HTML 标签
  REQUIRED_TAGS: ['html', 'head', 'body'],
  
  // 推荐的 HTML 标签
  RECOMMENDED_TAGS: ['title', 'meta'],
  
  // 语义化标签
  SEMANTIC_TAGS: ['header', 'nav', 'main', 'section', 'article', 'aside', 'footer']
} as const

// 错误消息
export const ERROR_MESSAGES = {
  EMPTY_CODE: '请先输入HTML代码再提交！',
  NO_ASSIGNMENT: '请先选择一个题目！',
  INVALID_HTML: 'HTML代码格式不正确，请检查语法！',
  SUBMISSION_FAILED: '提交失败，请重试！',
  GRADING_FAILED: '评分失败，请重试！',
  SAVE_FAILED: '保存失败，请重试！',
  LOAD_FAILED: '加载失败，请刷新页面重试！'
} as const

// 成功消息
export const SUCCESS_MESSAGES = {
  SUBMISSION_SUCCESS: '作业提交成功！',
  SAVE_SUCCESS: '代码保存成功！',
  RESET_SUCCESS: '代码已重置到初始模板',
  CLEAR_SUCCESS: '代码已清空',
  PREVIEW_UPDATED: '预览已更新！'
} as const

// 应用元信息
export const APP_META = {
  NAME: 'Vue Lab Project',
  VERSION: '1.0.0',
  DESCRIPTION: 'HTML作业编辑和评分系统',
  AUTHOR: 'Vue Lab Team'
} as const

// 导出所有配置的类型
export type GradingThresholds = typeof GRADING_CONFIG.THRESHOLDS
export type MaxScores = typeof GRADING_CONFIG.MAX_SCORES
export type GradeMapping = typeof GRADING_CONFIG.GRADE_MAPPING
export type EditorDefaults = typeof EDITOR_CONFIG.DEFAULTS
export type KeyboardShortcuts = typeof KEYBOARD_SHORTCUTS
export type UIColors = typeof UI_CONFIG.COLORS
export type StorageKeys = typeof STORAGE_KEYS
export type ValidationRules = typeof VALIDATION_RULES